import cPickle

from common import *
from common.manager import Manager

class MEManager(Manager):
	"""
	This class is the Map Editor's manager.
	"""
	
	# Edition modes
	SCENARIO = 0
	UNITS = 1
	BUILDINGS = 2
	DOODADS = 3
	
	# Attributes
	edition_mode = SCENARIO
	glWidget = None
	hovered = None
	selected = None
	adding = None
	team = BLUE
	range = 1
	
	available_units = {}
	available_buildings = {}
	available_doodads = {}
	
	# Map-related
	terrain = None
	
	@staticmethod
	def initialize(map):
		Manager.initialize(map)
	
	@staticmethod
	def set_edition_mode(newMode):
		"""
		Changes the edition mode to a new one.
		"""
		
		MEManager.hovered = None
		MEManager.selected = None
		MEManager.adding = None
		
		MEManager.edition_mode = newMode

	@staticmethod
	def updateGL():
		if not(MEManager.glWidget is None):
			MEManager.glWidget.updateGL()